home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-04-16 | 4.2 KB | 132 lines | [TEXT/CWIE] |
- // RankedAccessor.h
- // Copyright: © 1994 - 1996-1997 - 1998 by Apple Computer, Inc., all rights reserved.
- /// abstract accessessor that defines interface for ranked searching,
- /// whether with a vector or an inverted index.
- #pragma once
-
- #ifndef RankedAccessor_h
- #define RankedAccessor_h
-
- #pragma import on
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=power
- #endif
-
- #include "IAAccessor.h"
- #include "TermIndex.h"
-
- #pragma IA_BEGIN_EXPORTS
-
- struct RankedQueryDoc { // have to know which index each document belongs to
- RankedQueryDoc();
- RankedQueryDoc(IADoc* doc, TermIndex* index);
- IADoc* doc;
- TermIndex* index;
- };
-
- class RankedHit : public IAHit {
- public:
- RankedHit(IAIndex* i, IADoc* d, float s, IATerm** ts, uint32 l);
- ~RankedHit(); // deletes matchingTerms
-
- RankedHit* DeepCopy() const; // copies matchingTerms
-
- void SetScore(float value){score = value;}
- float GetScore() const {return score;}
- IATerm** GetMatchingTerms() const {return matchingTerms;}
- uint32 GetMatchingTermsLen() const {return matchingTermsLen;}
-
-
- private:
- RankedHit(RankedHit&);
- float score;
- IATerm** matchingTerms; // top scoring terms in intersection of doc w/ query
- uint32 matchingTermsLen;
-
-
- };
-
- class RankedProgress : public IAProgressReport {
- public:
- RankedProgress() : fTerm(NULL), IAProgressReport() {}
- IA_INLINE ~RankedProgress() IA_INLINE_DEF() // no-op dtor def
- IATerm* GetTerm() const {return fTerm;}
- void SetTerm(IATerm* term) {fTerm = term;}
- private:
- IATerm* fTerm; // when non-NULL, names term currently being processed.
- };
- typedef bool RankedProgressFn(const RankedProgress* progress, void* data);
-
- class Similarity;
- class IAQuery;
- class WeightedTermQueue;
-
- class RankedAccessor : public IAAccessor {
- public:
- RankedAccessor(IAIndex** indices, uint32 indexCount, uint32 type);
- ~RankedAccessor();
-
- virtual uint32 RankedSearch(byte* textQuery, uint32 textQueryLen,
- RankedQueryDoc* docQuery, uint32 nDocs,
- RankedHit** results, uint32 resultLen,
- uint32 matchingTermsLen,
- RankedProgressFn* progressFn,
- clock_t progressFreq,
- void* appData) = 0;
-
- virtual uint32 RankedSearch(IADocText* textQuery,
- RankedQueryDoc* docQuery, uint32 nDocs,
- RankedHit** results, uint32 resultLen,
- uint32 matchingTermsLen,
- RankedProgressFn* progressFn,
- clock_t progressFreq,
- void* appData) = 0;
-
- virtual uint32 GetDocTopic(RankedQueryDoc* doc,
- IATerm** results, uint32 resultLen,
- RankedProgressFn* progressFn,
- clock_t progressFreq,
- void* appData);
-
- virtual uint32 GetTermsRelated(byte* term, uint32 termLen,
- IATerm** results, uint32 resultLen,
- RankedProgressFn* progressFn,
- clock_t progressFreq,
- void* appData);
-
- // called to filter hits -- default always returns true
- virtual bool IsHit(IAIndex* index, const IADoc* doc);
- // determines merging of hits -- defaults are d1->LessThan(d2) and d1->Equal(d2)
- virtual bool HitLessThan(IAIndex* i1, const IADoc* d1, IAIndex* i2, const IADoc* d2);
- virtual bool HitEqual(IAIndex* i1, const IADoc* d1, IAIndex* i2, const IADoc* d2);
- // merges hits that are HitEqual() into one hit -- default copies higher scoring
- virtual RankedHit* MergeHits(const RankedHit* hit1, const RankedHit* hit2);
- protected:
- Similarity* GetSimilarity() const {return sim;}
- // default constructor etc. so that this can be a virtual base class
- RankedAccessor();
- void Constructing(IAIndex** indices, uint32 indexCount, uint32 type);
- bool IsRankedCoordinated() const {return RankedCoordination;}
- void SetRankedCoordination(bool coord = true) {RankedCoordination = coord;}
- void SetRankedCoordinationDegree(float deg);
- float GetRankedCoordinationDegree() const;
- private:
- uint32 GetDocTopicInternal(RankedQueryDoc* doc,
- WeightedTermQueue* results, uint32 resultLen,
- RankedProgressFn* progressFn,
- clock_t progressFreq,
- void* appData);
-
- Similarity* sim;
- bool RankedCoordination; // Determines whether short queries use coordination ranking.
- };
-
- #pragma IA_END_EXPORTS
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
- #endif
-
- #pragma import reset
- #endif